package com.tofine.smarthome.model;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.bignerdranch.expandablerecyclerview.Model.ParentListItem;
import com.google.gson.annotations.Expose;

import java.io.Serializable;
import java.util.List;

/**
 * @author ddMax
 * @since 2016/5/3 20:10.
 */
@Table(name = "Rooms")
public class Room extends Model implements Serializable, ParentListItem {

    @Column(name = "_id")
    public String _id;
    @Column(name = "image")
    public String image;
    @Column(name = "name")
    @Expose
    public String name;

    public List<Device> devices() {
        return getMany(Device.class, "Room");
    }

    public Room(String image, String name) {
        this.image = image;
        this.name = name;
    }

    public Room(String _id, String image, String name) {
        this._id = _id;
        this.image = image;
        this.name = name;
    }

    public Room() {}

    @Override
    public List<?> getChildItemList() {
        return this.devices();
    }

    @Override
    public boolean isInitiallyExpanded() {
        return false;
    }

    @Override
    public String toString() {
        return "Room{" +
                "_id='" + _id + '\'' +
                ", image='" + image + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
